package jaux.tank.admin.modular.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import jaux.tank.bean.entity.system.Attachment;
import jaux.tank.dao.system.AttachmentRepository;

@Controller
@RequestMapping("/attachment")
public class AttachmentController {
	@Autowired
    private AttachmentRepository attachmentRepo;
    private static String PREFIX = "/system/attachment/";
    /**
     * 跳转到附件管理首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "attachment.html";
    }

    /**
     * 跳转到添加附件
     */
    @RequestMapping("/attachment_add")
    public String add() {
        return PREFIX + "attachment_add.html";
    }

    /**
     * 跳转到修改附件
     */
    @RequestMapping("/attachment_update/{attachmentId}")
    public String update(@PathVariable String attachmentId, Model model) {
        Attachment attachment = attachmentRepo.findById(attachmentId).orElse(null);
        model.addAttribute("item",attachment);
        return PREFIX + "attachment_edit.html";
    }

   
}
